#if 0
#include "usart.h"
#include "cli.h"
#include "cli_app.h"
#include "nr_micro_shell.h"


#define SYSTEM_VERSION "V1.00"

int do_sysinfo_handler(cli_obj_t *o, int argc, char *argv[]);

cmd_item_t cmd_item_manage[] = {
    {"sysinfo", do_sysinfo_handler, "show system infomation"},
    {"help",    do_help, "list all command"},
    {"?",       do_help, "alias for 'help'"},
};

static cli_obj_t cli;
int cmd_manage_num = sizeof(cmd_item_manage)/sizeof(cmd_manage_t);

int do_sysinfo_handler(cli_obj_t *o, int argc, char *argv[])
{
    printf("|*************************************************************|\r\n");  
    printf("|                            \\\\\\|///                          |\r\n");
    printf("|                            \\- - -/                          |\r\n");
    printf("|                           (  @ @  )                         |\r\n");
    printf("|  +----------------------o00o-(_)-o00o---------------------+ |\r\n");
    printf("|  |                                                        | |\r\n");
    printf("|  | Project Name :        FreeRTOS                         | |\r\n");
    printf("|  |--------------------------------------------------------| |\r\n");
    printf("|  | Author      :  ZZH                                     | |\r\n");
    printf("|  | Contact     :                                          | |\r\n");
    printf("|  |                                                        | |\r\n");
    printf("|  |                               Oooo                     | |\r\n");  
    printf("|  +---------------------- oooO---(   )---------------------+ |\r\n");
    printf("|                          (   )   ) /                        |\r\n");
    printf("|                           \\ (   (_/                         |\r\n");
    printf("|                            \\_)                              |\r\n");
    printf("|*************************************************************|\r\n\r\n");
    
    printf("Build in %s %s\r\n",__DATE__,__TIME__);
    printf("Software version: %s\r\n", SYSTEM_VERSION);
    printf("System clock: %d hz\r\n", SystemCoreClock);   
    return 1;
}

void cli_task_init(void)
{
    cli_port_t p = {tty.write, tty.read};

		cmd_manage_init();
//    register_cmd_manage(&cmd_item_manage[0], cmd_manage_num);
		register_cmd(&cmd_item_manage[0]);
		register_cmd(&cmd_item_manage[1]);
		register_cmd(&cmd_item_manage[2]);
		
    cli_init(&cli, &p);
    cli_enable(&cli);
    cli_exec_cmd(&cli, "sysinfo");
}


void cli_task(void)
{
    while(1) {
        cli_process(&cli);
        vTaskDelay(200);
    }
}
#else

#include "cli_app.h"
#include "usart.h"
#include "nr_micro_shell.h"
#include <string.h>
#include <ctype.h>



#define SYSTEM_VERSION "V1.00"

/**
 * @brief ls command
 */
void shell_ls_cmd(char argc, char *argv)
{
	unsigned int i = 0;
	if (argc > 1)
	{
		if (!strcmp("cmd", &argv[argv[1]]))
		{
			for (i = 0; nr_shell.static_cmd[i].fp != NULL; i++)
			{
				shell_printf("%s",nr_shell.static_cmd[i].cmd);
				shell_printf("\r\n");
			}
		}
		else if (!strcmp("-v", &argv[argv[1]]))
		{
            shell_printf("Build in %s %s\r\n",__DATE__,__TIME__);
            shell_printf("Software version: %s\r\n", SYSTEM_VERSION);
            shell_printf("System clock: %d hz\r\n", SystemCoreClock);   
		}
		else if (!strcmp("-h", &argv[argv[1]]))
		{
			shell_printf("useage: ls [options]\r\n");
			shell_printf("options: \r\n");
			shell_printf("\t -h \t: show help\r\n");
			shell_printf("\t -v \t: show version\r\n");
			shell_printf("\t cmd \t: show all commands\r\n");

		}
	}
	else
	{
		shell_printf("ls need more arguments!\r\n");
	}
}

/**
 * @brief test command
 */
void shell_test_cmd(char argc, char *argv)
{
	unsigned int i;
	shell_printf("test command:\r\n");
	for (i = 0; i < argc; i++)
	{
		shell_printf("paras %d: %s\r\n", i, &(argv[argv[i]]));
	}
}

void shell_led_cmd(char argc, char *argv)
{
    if(argc > 1) {
        if (!strcmp("on", &argv[argv[1]])) {
			led_on();
		} else if(!strcmp("off", &argv[argv[1]])) {
            led_off();
        }
    } else {
        shell_printf("led need more arguments!\r\n");
    }
}

const static_cmd_st static_cmd[] =
{
	{"ls", shell_ls_cmd},
	{"test", shell_test_cmd},
    {"led", shell_led_cmd},
	{"\0", NULL}
};

void cli_task(void *param)
{
    char ch = 0;

    while(1) 
    {
        if(!tty.rx_isempty()) {
			tty.read(&ch,1);
            shell(ch);
        }
        vTaskDelay(10);
    }
}


#endif



